<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.util.ValueUtil"%>
<%@page import="com.shsh.safemanage.model.ProblemBrowseCondition"%>
<%@page import="java.util.Calendar"%>
<%@page import="com.shsh.safemanage.dao.EquipmentDao"%>
<%@page import="com.shsh.safemanage.model.Equipment"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>
<%@page import="com.shsh.safemanage.model.Department1"%>

<%
DepartmentDao departmentDao = DaoCreator.createDepartmentDao();
EquipmentDao equipmentDao = DaoCreator.createEquipmentDao();

String theFromPage = request.getParameter(Constants.REQUEST_PARAMETER_FROM_PAGE);
if (theFromPage == null || !theFromPage.equals("feedback")) {
	session.removeAttribute(Constants.SESSION_PROBLEM_CONDITION);
}
%>

<script type="text/javascript">
<%
ProblemBrowseCondition theCondition = (ProblemBrowseCondition) session.getAttribute(Constants.SESSION_PROBLEM_CONDITION);
%>
function initPageValues() {
	setElementValueByID('equipID', '');
<%
if (theCondition != null) {
%>
	var listTypeStr = '<%=ValueUtil.getString(theCondition.getListTypeStr())%>';
	var depart1IDStr = '<%=ValueUtil.getString(theCondition.getDepart1IDStr())%>';
	var equipIDStr = '<%=ValueUtil.getString(theCondition.getEquipIDStr())%>';
	var problemTitle = '<%=ValueUtil.getString(theCondition.getProblemTitle())%>';
	var problemContent = '<%=ValueUtil.getString(theCondition.getProblemContent())%>';
	var dateStart = '<%=ValueUtil.getString(theCondition.getDateStart())%>';
	var dateEnd = '<%=ValueUtil.getString(theCondition.getDateEnd())%>';
	var writerManageGroupIDStr = '<%=ValueUtil.getString(theCondition.getWriterManageGroupID())%>';
	var writerDepartment1IDStr = '<%=ValueUtil.getString(theCondition.getWriterDepartment1ID())%>';
	var writerDepartment2IDStr = '<%=ValueUtil.getString(theCondition.getWriterDepartment2ID())%>';
	
	setElementValueByID('listType', listTypeStr);
	setElementValueByID('depart1', depart1IDStr);
	loadPageSection('<%=request.getContextPath()%>/equip_select/equipment_of_depart_select_section.jsp','equipOfDepartSpan', {
			depart1ID : depart1IDStr
		}, false, function() {
			setElementValueByID('equipID', equipIDStr);
		}
	);
	loadPageSection('<%=request.getContextPath()%>/managegroup_select/manage_group_select_section.jsp',
		'manageGroupSpan', {
		depart1ID : depart1IDStr
		}, false, function() {
			setElementValueByID('manageGroupID', writerManageGroupIDStr);
		}
	);
	setElementValueByID('depart1_1', writerDepartment1IDStr);
	loadPageSection('<%=request.getContextPath()%>/depart_select/depart2_select_section.jsp', 'depart2OfDepart1Span', 
			{depart1ID: writerDepartment1IDStr}, false, function() {
				setElementValueByID('depart2', writerDepartment2IDStr);
			});
	setElementValueByID('problemTitle', problemTitle);
	setElementValueByID('problemContent', problemContent);
	setElementValueByID('dateStart', dateStart);
	setElementValueByID('dateEnd', dateEnd);
<%
}
%>
}
</script>
<div class="hider" id="hider">
	<span>&nbsp;</span>
</div>
<div class="position">
	<img src="images/position2.jpg" style="padding: 7px 9px; float: left;" />当前位置：上海高桥分公司问题管理平台
	&gt;&gt; HSE观察浏览
</div>
<div class="tt">HSE观察浏览</div>
<div class="content">
	<div class="apptab">
		<table width="100%" border="0" cellpadding="0" cellspacing="0"
			style="font-size: 12px; color: #000; line-height: 25px;">
			<tr>
				<td width="13" class="appbg">&nbsp;</td>
				<td width="97" class="appbg"><img src="images/trace.gif"
					style="vertical-align: middle;" />查询条件</td>
				<td width="554" class="appbg">&nbsp;</td>
				<td colspan="2" class="appbg">&nbsp;</td>
			</tr>
			<tr>
				<td width="13" height="40">&nbsp;</td>
				<td colspan="3">
					<span style="margin-left: 30px">生成类型：</span>
					<select name="listType" id="listType">
						<option value="1">HSE观察记录汇总表</option>
						<option value="2">HSE观察月报</option>
						<option value="3">公司HSE督察员观察记录汇总表</option>
					</select>
					
					<br />
					
					<span style="margin-left: 30px">作业部：</span>
					<span> 
					<%@include file="depart_select/depart1_shiyebu_select_section.jsp"%>
					</span> 
					<span style="margin-left: 10px">装置：</span> 
					<span id="equipOfDepartSpan">
						<%@include file="equip_select/equipment_of_depart_select_section.jsp"%>
					</span>
					<span style="margin-left: 10px">管理组：</span>
					<span id="manageGroupSpan">
						<%@include file="managegroup_select/manage_group_select_section.jsp"%>
					</span>
					 
					<br />
					
					<span style="margin-left: 30px">填报人单位：</span>
					<span>
						<%@include file="depart_select/depart1_1_select_section.jsp" %>
					</span>
					<span id="depart2OfDepart1Span">
						<%@include file="depart_select/depart2_select_section.jsp"%>
					</span>
					<br />
					
					<span style="margin-left: 30px">问题标题： </span><input type="text" size="15" id="problemTitle" />
					<span style="margin-left: 10px">全文： </span><input type="text" size="25" id="problemContent" />
					<font color="#666666">（可模糊查询相关文字）</font>
					
					<br />
					
					<span style="margin-left: 30px">填报日期区间：</span> <input type="text" id="dateStart"
					size="15"
					onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'dateStart\')||\'2050-12-31\'}'})" />-<input
					type="text" id="dateEnd" size="15"
					onfocus="WdatePicker({minDate:'#F{$dp.$D(\'dateEnd\')}',maxDate:'2050-12-31'})" />
				</td>
				<td width="14">&nbsp;</td>
			</tr>
			<tr>
				<td width="13" height="40">&nbsp;</td>
				<td colspan="3" style="text-align: center;"><a
					href="javascript:" onclick="browseProblems(1)"><img
						src="images/cha.gif" /></a></td>
				<td width="14">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="5">
				<span id="monthSpan">
					<%@include file="month_href_section.jsp" %>
				</span>
				</td>
			</tr>
			<tr>
				<td colspan="5" height="20">&nbsp;</td>
			</tr>
		</table>
	</div>
	<script type="text/javascript">
	initPageValues();
	</script>
	<div class="apptab" id="problemBrowseListTD">
	<%
	ProblemBrowseCondition condition = (ProblemBrowseCondition) session.getAttribute(Constants.SESSION_PROBLEM_CONDITION);
	if (condition == null) {
	%>
	<%@include file="user_related_problem_list.jsp"%>
	<%
	} else {
		if (condition.getListTypeStr() == null || condition.getListTypeStr().equals("1")) {
	%>
	<%@include file="problem_list.jsp"%>
	<%
		} else if (condition.getListTypeStr().equals("2")) {
	%>
	<%@include file="hse/month_report.jsp"%>
	<%
		} else if (condition.getListTypeStr().equals("3")) {
	%>
	<%@include file="problem_duchayuan_list.jsp"%>
	<%
		} else {
	%>
	<%@include file="problem_list.jsp"%>
	<%
		}
	}
	%>
	</div>
</div>

<script type="text/javascript">
function browseProblems(pageNum) {
	openWaitingDialog('waitingDialog');
	
	var listType = getElementValueByID('listType');
	var roleLevel = 0;
	if (listType == '3') {
		roleLevel = 3;
	}
	
	loadPageSection('<%=request.getContextPath()%>/problem_search_list.jsp', 'problemBrowseListTD', 
		{
			departmentID : getElementValueByID('depart1'),
			equipID : getElementValueByID('equipID'),
			problemTitle : getElementValueByID('problemTitle'),
			problemContent : getElementValueByID('problemContent'),
			dateStart : getElementValueByID('dateStart'),
			dateEnd : getElementValueByID('dateEnd'),
			manageGroupID : getElementValueByID('manageGroupID'),
			depart1ID_1: getElementValueByID('depart1_1'),
			depart2ID: getElementValueByID('depart2'),
			listType: getElementValueByID('listType'),
			problemType: 0,
			pageNum: pageNum,
			roleLevel: roleLevel
		},
		true
	);
}

function browseAllProblemByMonth(dateStart, dateEnd) {
	setElementValueByID('dateStart', dateStart);
	setElementValueByID('dateEnd', dateEnd);
	
	var listType = getElementValueByID('listType');
	var roleLevel = 0;
	if (listType == '3') {
		roleLevel = 3;
	}
	
	loadPageSection('<%=request.getContextPath()%>/problem_search_list.jsp', 'problemBrowseListTD', 
		{
			dateStart : dateStart,
			dateEnd : dateEnd,
			problemType: 0,
			listType: getElementValueByID('listType'),
			departmentID : getElementValueByID('depart1'),
			equipID : getElementValueByID('equipID'),
			problemTitle : getElementValueByID('problemTitle'),
			problemContent : getElementValueByID('problemContent'),
			manageGroupID : getElementValueByID('manageGroupID'),
			depart1ID_1: getElementValueByID('depart1_1'),
			depart2ID: getElementValueByID('depart2'),
			roleLevel: roleLevel
		}, 
		true
	);
}

function browseOverallProblems(pageNum) {
	var listType = getElementValueByID('listType');
	var roleLevel = 0;
	if (listType == '3') {
		roleLevel = 3;
	}
	
	loadPageSection('<%=request.getContextPath()%>/problem_search_list.jsp', 'problemBrowseListTD', 
	{
		departmentID : getElementValueByID('depart1'),
		equipID : getElementValueByID('equipID'),
		problemTitle : getElementValueByID('problemTitle'),
		problemContent : getElementValueByID('problemContent'),
		dateStart : getElementValueByID('dateStart'),
		dateEnd : getElementValueByID('dateEnd'),
		manageGroupID : getElementValueByID('manageGroupID'),
		depart1ID_1: getElementValueByID('depart1_1'),
		depart2ID: getElementValueByID('depart2'),
		listType: getElementValueByID('listType'),
		problemType: 0,
		pageNum: pageNum,
		roleLevel: roleLevel
	}, 
	true
	);
}

function selectDepart1() {
	loadPageSection('<%=request.getContextPath()%>/equip_select/equipment_of_depart_select_section.jsp',
			'equipOfDepartSpan', 
			{
				depart1ID : getElementValueByID('depart1')
			}, 
			false, 
			function() {
				document.getElementById('equipID').value = '';
			}
	);
	loadPageSection('<%=request.getContextPath()%>/managegroup_select/manage_group_select_section.jsp',
		'manageGroupSpan', 
		{
			depart1ID : getElementValueByID('depart1')
		}, 
		false, 
		function() {
			document.getElementById('manageGroupID').value = '';
		}
	);
}

function selectDepart1_1() {
	loadPageSection('<%=request.getContextPath()%>/depart_select/depart2_select_section.jsp', 'depart2OfDepart1Span', 
		{
			depart1ID: getElementValueByID('depart1_1')
		}
	);
}
</script>
